package io.renren.constant;

import com.vortex.tool.httpclient.credential.VtxCredential;
import com.vortex.tool.httpclient.credential.VtxDefaultCredential;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zhangxu
 * @create 2020/8/25
 * Description:
 */
public class DeviceFinal {

    private static Logger logger = LoggerFactory.getLogger(DeviceFinal.class);
    public static final VtxCredential credential = new VtxDefaultCredential("7468f427a7b1441a82a7a0b78b896794", "c8c812a3074c420ea2137682d1cc5a73");
    public static final String device_url = "http://api2.envcloud.com.cn:8082/sds/deviceFactorData/getRealTimeDataBatch";

    //设备运行时间开始值
    public static final String runtimeStr = "2020/09/01 00:00:00";

    //设备编码常量-start
    public static final String gas_encrypt_01 = "HJ21220200823001";
    public static final String gas_encrypt_02 = "HJ21220200823002";
    public static final String gas_encrypt_03 = "HJ21220200823003";
    public static final String gas_encrypt_04 = "HJ21220200823004";
    public static final String gas_encrypt_05 = "HJ21220200823005";
    public static final String gas_encrypt_06 = "HJ21220200823006";
    public static final String water_encrypt_01 = "HJ212A1100000001";
    public static final String water_encrypt_02 = "HJ212A1100000002";
    public static final String water_encrypt_03 = "HJ212A1100000003";
    public static final String water_encrypt_04 = "HJ212A1100000004";
    public static final String water_encrypt_05 = "HJ212A1100000005";
    public static final String pm25_encrypt_01 = "HJ21220200901001";
    public static final String pm25_encrypt_02 = "HJ21220200901002";
    public static final String pm25_encrypt_03 = "HJ21220200901003";
    public static final String pm25_encrypt_04 = "HJ21220200901004";
    public static final String doppler_encrypt_01 = "Toran441080000013489";//Toran1440330101979被废弃
    public static final String doppler_encrypt_02 = "Toran1440330101979";//Toran1440330101979被废弃
    public static final String smoke_encrypt_01 = "SMOKE00001";
    public static final String tsp_encrypt_01 = "TSP00001";
    public static final String combalarm_encrypt_01 = "HJ21220201001001";
    public static final String combalarm_encrypt_02 = "HJ21220201001002";
    public static final String combalarm_encrypt_03 = "HJ21220201001003";
    public static final String combalarm_encrypt_04 = "HJ21220201001004";
    public static final String combalarm_encrypt_05 = "HJ21220201001005";
    public static final String combalarm_encrypt_06 = "HJ21220201001006";
    public static final String combalarm_encrypt_07 = "HJ21220201001007";
    public static final String combalarm_encrypt_08 = "HJ21220201001008";
    public static final String combalarm_encrypt_09 = "HJ21220201001009";
    public static final String dahua_encrypt_02 = "ZHYQ002";
    public static final String dahua_encrypt_03 = "ZHYQ003";
    public static final String dahua_encrypt_04 = "ZHYQ004";
    public static final String dahua_encrypt_05 = "ZHYQ005";
    public static final String dahua_encrypt_06 = "ZHYQ006";
    public static final String dahua_encrypt_07 = "ZHYQ007";
    public static final String dahua_encrypt_08 = "ZHYQ008";
    public static final String dahua_encrypt_09 = "ZHYQ009";
    public static final String dahua_encrypt_10 = "ZHYQ010";
    public static final String huohua_encrypt_1 = "HJ212CZSGZHYQ2020110501";
    public static final String huohua_encrypt_2 = "HJ212CZSGZHYQ2020110502";
    public static final String huohua_encrypt_3 = "HJ212CZSGZHYQ2020110503";
    public static final String huohua_encrypt_4 = "HJ212CZSGZHYQ2020110504";
    public static final String huohua_encrypt_5 = "HJ212CZSGZHYQ2020110505";
    //设备编码常量-end


    //指标值-start
    //气体指标
    public static final String GAS_Quota_a05002_Rtd = "a05002-Rtd";
    public static final String GAS_Quota_a24087_Rtd = "a24087-Rtd";
    public static final String GAS_Quota_a24088_Rtd = "a24088-Rtd";
    public static final String GAS_Quota_a01007_Rtd = "a01007-Rtd";
    public static final String GAS_Quota_a01002_Rtd = "a01002-Rtd";
    public static final String GAS_Quota_a01001_Rtd = "a01001-Rtd";
    public static final String GAS_Quota_a01008_Rtd = "a01008-Rtd";
    public static final String GAS_Quota_a01006_Rtd = "a01006-Rtd";
    //水质指标
    public static final String WATER_Quota_w21003_Rtd = "w21003-Rtd";
    public static final String WATER_Quota_w21011_Rtd = "w21011-Rtd";
    public static final String WATER_Quota_w01003_Rtd = "w01003-Rtd";
    public static final String WATER_Quota_w01001_Rtd = "w01001-Rtd";
    //pm25设备
    public static final String PM_25_Quota_a34004_Avg = "a34004-Avg";
    //TSP
    public static final String TSP_Quota_a01001_Rtd = "a01001-Rtd";
    public static final String TSP_Quota_a01002_Rtd = "a01002-Rtd";
    public static final String TSP_Quota_a01007_Rtd = "a01007-Rtd";
    public static final String TSP_Quota_a01008_Rtd = "a01008-Rtd";
    public static final String TSP_Quota_a01006_Rtd = "a01006-Rtd";
    public static final String TSP_Quota_a34001_Rtd = "a34001-Rtd";
    public static final String TSP_Quota_a34004_Rtd = "a34004-Rtd";
    public static final String TSP_Quota_a34002_Rtd = "a34002-Rtd";
    //禾风-烟气在线
    public static final String SMOKE_02_Rtd = "02-Rtd";
    public static final String SMOKE_03_Rtd = "03-Rtd";
    public static final String SMOKE_S01_Rtd = "S01-Rtd";
    public static final String SMOKE_S03_Rtd = "S03-Rtd";
    public static final String SMOKE_S08_Rtd = "S08-Rtd";
    public static final String SMOKE_S02_Rtd = "S02-Rtd";
    public static final String SMOKE_01_Rtd = "01-Rtd";
    public static final String SMOKE_S05_Rtd = "S05-Rtd";
    //瀚沃-多普勒超声波流量计（六小时一次数据）
    public static final String SWEAGE_Ch1="Ch1";
    public static final String SWEAGE_Ch2="Ch2";
    public static final String SWEAGE_Ch3="Ch3";
    public static final String SWEAGE_Ch4="Ch4";
    public static final String SWEAGE_Ch5="Ch5";
    //可燃报警
    public static final String COMBALARM_a34041_Avg="a34041-Avg";
    //火花设备指标
    public static final String huohua_Czsgzhyq_Hhs_Rtd = "czsgzhyq-hhs-Rtd";
    //指标值-end



    //设备类型-start
    public static final String tsp_type = "tsp_type";
    public static final String smoke_type = "smoke_type";
    public static final String vocs_type = "vocs_type";
    public static final String pm25_type = "pm25_type";
    public static final String water_type = "water_type";
    public static final String sweage_type = "sweage_type";
    public static final String vedio_type = "vedio_type";
    public static final String combustibl_type = "combustibl_type";
    public static final String huohua_type = "huohua_type";
    //设备类型-end

    public static final String tuanrui_water_address = "tuanrui_water_address";
    public static final String device_type = "device_type";
    //各个数据常量定义-end

    //-------指标超标常量组-start
    //超标常量值设置，DeviceWarningQuota的rangeEnum用到
    public static final String actual_warning = "actual_warning";//实时超标
    public static final String hour_warning = "hour_warning";
    public static final String day_warning = "day_warning";
    public static final String year_warning = "year_warning";

    //实时超标
    //多普勒超声波流量计（六小时一次数据）
    public static final BigDecimal ACTUAL_SWEAGE_Ch1 = new BigDecimal("15");
    //多普勒超声波流量计（六小时一次数据）
    public static final BigDecimal ACTUAL_Czsgzhyq_Hhs_Rtd = new BigDecimal("1");

    //小时指标超标值-start
    //挥发性有机物在线监测（VOCs）
    public static final BigDecimal HOUR_GAS_Quota_a24088_Rtd = new BigDecimal("4");
    public static final BigDecimal HOUR_GAS_Quota_a05002_Rtd = new BigDecimal("0.36");
    public static final BigDecimal HOUR_GAS_Quota_a24087_Rtd = new BigDecimal("0.3");
    //聚光  水质设备
    public static final BigDecimal HOUR_WATER_Quota_w21003_Rtd = new BigDecimal("1");
    public static final BigDecimal HOUR_WATER_Quota_w21011_Rtd = new BigDecimal("0.2");
    public static final BigDecimal HOUR_WATER_Quota_w01001_Rtd_more = new BigDecimal("9");
    public static final BigDecimal HOUR_WATER_Quota_w01001_Rtd_less = new BigDecimal("6");
    //烟气在线监测
    public static final BigDecimal HOUR_SMOKE_02_Rtd = new BigDecimal("60");
    public static final BigDecimal HOUR_SMOKE_03_Rtd = new BigDecimal("50");
    public static final BigDecimal HOUR_SMOKE_01_Rtd = new BigDecimal("200");
    //小时指标超标值-end

    //24小时指标超标值-start
    //tsp超标
    public static final BigDecimal DAY_TSP_Quota_a34001_Rtd = new BigDecimal("300");
    public static final BigDecimal DAY_TSP_Quota_a34004_Rtd = new BigDecimal("75");
    //PM2.5超标
    public static final BigDecimal DAY_PM_25_Quota_a34004_Avg = new BigDecimal("75");
    //挥发性有机物在线监测（VOCs）
    public static final BigDecimal DAY_GAS_Quota_a05002_Rtd = new BigDecimal("0.12");
    //烟气在线监测
    public static final BigDecimal DAY_SMOKE_02_Rtd = new BigDecimal("150");
    public static final BigDecimal DAY_SMOKE_03_Rtd = new BigDecimal("100");
    //24小时指标超标值-end

    //年指标超标值-start
    //tsp超标
    public static final BigDecimal YEAR_TSP_Quota_a34001_Rtd = new BigDecimal("200");
    public static final BigDecimal YEAR_TSP_Quota_a34004_Rtd = new BigDecimal("35");
    //PM2.5超标
    public static final BigDecimal YEAR_PM_25_Quota_a34004_Avg = new BigDecimal("35");
    //烟气在线监测
    public static final BigDecimal YEAR_SMOKE_02_Rtd = new BigDecimal("500");
    public static final BigDecimal YEAR_SMOKE_03_Rtd = new BigDecimal("250");
    //年指标超标值-end
    //-------指标超标常量组-end

    public static final String[] device_gas_code_arr = new String[]{
            gas_encrypt_01,gas_encrypt_02,gas_encrypt_03,gas_encrypt_04,gas_encrypt_05,gas_encrypt_06
    };
    public static final String[] device_water_code_arr = new String[]{
            water_encrypt_01,water_encrypt_02,water_encrypt_03,water_encrypt_04,water_encrypt_05
    };
    public static final String[] device_pm25_code_arr = new String[]{
            pm25_encrypt_01,pm25_encrypt_02,pm25_encrypt_03,pm25_encrypt_04
    };
    public static final String[] device_doppler_code_arr = new String[]{
            doppler_encrypt_01,doppler_encrypt_02
    };
    public static final String[] device_dahua_code_arr = new String[]{
            dahua_encrypt_02,dahua_encrypt_03,dahua_encrypt_04,dahua_encrypt_05,
            dahua_encrypt_06,dahua_encrypt_07,dahua_encrypt_08,dahua_encrypt_09,dahua_encrypt_10
    };
    public static final String[] device_smokeonline_code_arr = new String[]{//烟气在线
            smoke_encrypt_01//暂时做假数据放这个
    };
    public static final String[] device_tsp_code_arr = new String[]{//tsp
            tsp_encrypt_01//暂时做假数据放这个
    };
    public static final String[] device_combalarm_code_arr = new String[]{//可燃报警
            combalarm_encrypt_01,combalarm_encrypt_02,combalarm_encrypt_03,combalarm_encrypt_04,combalarm_encrypt_05
            ,combalarm_encrypt_06,combalarm_encrypt_07,combalarm_encrypt_08,combalarm_encrypt_09
    };
    public static final String[] device_huohuam_code_arr = new String[]{//可燃报警
            huohua_encrypt_1,huohua_encrypt_2,huohua_encrypt_3,huohua_encrypt_4,huohua_encrypt_5
    };
    public static String[] device_all_code_arr;
    public static Map<String,Integer> device_all_code_map = new HashMap<>();

    public static Map<String,Map<String,String>> deviceCodeMap = new HashMap<>();
    public static Map<String,String> gasQuotaMap = new HashMap<>();
    public static Map<String,String> waterQuotaMap = new HashMap<>();
    public static Map<String,String> pm25QuotaMap = new HashMap<>();
    public static Map<String,String> tspQuotaMap = new HashMap<>();
    public static Map<String,String> smokeQuotaMap = new HashMap<>();
    public static Map<String,String> sweageQuotaMap = new HashMap<>();
    public static Map<String,String> combalarmQuotaMap = new HashMap<>();
    public static Map<String,String> huohuaQuotaMap = new HashMap<>();
    public static Map<String,String> allQuotaMap = new HashMap<>();//所有指标
    public static Map<String,String> allDayAvgQuotaMap = new HashMap<>();//需按天平均的指标，key为设备、value为指标
    public static Map<String,String> allYearAvgQuotaMap = new HashMap<>();//需按年平均的指标，key为设备、value为指标

    public static Map<String,String> tuanruiWaterAddressMap = new HashMap<>();
    //public static Map<String,String> tuanruiWaterCodeMap = new HashMap<>();

    public static Map<String,String> devictTypeMap = new HashMap<>();


    static {
        gasQuotaMap.put(GAS_Quota_a05002_Rtd,"甲烷（mg/m3）");
        gasQuotaMap.put(GAS_Quota_a24087_Rtd,"碳氢化合物（mg/m3）");
        gasQuotaMap.put(GAS_Quota_a24088_Rtd,"非甲烷总烃（mg/m3）");
        gasQuotaMap.put(GAS_Quota_a01007_Rtd,"风速（m/s）");
        gasQuotaMap.put(GAS_Quota_a01002_Rtd,"湿度（%RH）");
        gasQuotaMap.put(GAS_Quota_a01001_Rtd,"温度（℃）");
        gasQuotaMap.put(GAS_Quota_a01008_Rtd,"风向（°）");
        gasQuotaMap.put(GAS_Quota_a01006_Rtd,"气压（Pa）");
        deviceCodeMap.put(vocs_type,gasQuotaMap);

        waterQuotaMap.put(WATER_Quota_w21003_Rtd,"氨氮（mg/L）");
        waterQuotaMap.put(WATER_Quota_w21011_Rtd,"总磷（mg/L）");
        waterQuotaMap.put(WATER_Quota_w01003_Rtd,"浊度（mg/L）");
        waterQuotaMap.put(WATER_Quota_w01001_Rtd,"PH值");
        deviceCodeMap.put(water_type,waterQuotaMap);

        pm25QuotaMap.put(PM_25_Quota_a34004_Avg,"PM2.5（ug/m3）");
        deviceCodeMap.put(pm25_type,pm25QuotaMap);

        tspQuotaMap.put(TSP_Quota_a01001_Rtd,"温度（℃）");
        tspQuotaMap.put(TSP_Quota_a01002_Rtd,"湿度（%RH）");
        tspQuotaMap.put(TSP_Quota_a01007_Rtd,"风速（m/s）");
        tspQuotaMap.put(TSP_Quota_a01008_Rtd,"风向（°）");
        tspQuotaMap.put(TSP_Quota_a01006_Rtd,"气压（Kpa）");
        tspQuotaMap.put(TSP_Quota_a34001_Rtd,"TSP（ug/m3）");
        tspQuotaMap.put(TSP_Quota_a34004_Rtd,"PM2.5（g/m3）");
        tspQuotaMap.put(TSP_Quota_a34002_Rtd,"PM10（ug/m3）");
        deviceCodeMap.put(tsp_type,tspQuotaMap);

        smokeQuotaMap.put(SMOKE_02_Rtd,"二氧化硫（mg/m3）");
        smokeQuotaMap.put(SMOKE_03_Rtd,"氮氧化物（mg/m3）");
        smokeQuotaMap.put(SMOKE_S01_Rtd,"氧气含量（%）");
        smokeQuotaMap.put(SMOKE_S03_Rtd,"烟气温度（摄氏度）");
        smokeQuotaMap.put(SMOKE_S08_Rtd,"烟气压力（Kpa）");
        smokeQuotaMap.put(SMOKE_S02_Rtd,"烟气流速（m/s）");
        smokeQuotaMap.put(SMOKE_01_Rtd,"粉尘（mg/m3）");
        smokeQuotaMap.put(SMOKE_S05_Rtd,"烟气湿度（%）");
        deviceCodeMap.put(smoke_type,smokeQuotaMap);

        sweageQuotaMap.put(SWEAGE_Ch1,"水深（mm）");
        sweageQuotaMap.put(SWEAGE_Ch2,"温度（m/s）");
        sweageQuotaMap.put(SWEAGE_Ch3,"温度（摄氏度）");
        sweageQuotaMap.put(SWEAGE_Ch4,"测量质量（%）");
        sweageQuotaMap.put(SWEAGE_Ch5,"流量（L/s）");
        deviceCodeMap.put(sweage_type,sweageQuotaMap);

        combalarmQuotaMap.put(COMBALARM_a34041_Avg,"气体浓度");
        deviceCodeMap.put(combustibl_type,combalarmQuotaMap);

        huohuaQuotaMap.put(huohua_Czsgzhyq_Hhs_Rtd,"火花报警");
        deviceCodeMap.put(huohua_type,huohuaQuotaMap);



        allQuotaMap.putAll(gasQuotaMap);
        allQuotaMap.putAll(waterQuotaMap);
        allQuotaMap.putAll(pm25QuotaMap);
        allQuotaMap.putAll(tspQuotaMap);
        allQuotaMap.putAll(smokeQuotaMap);
        allQuotaMap.putAll(sweageQuotaMap);
        allQuotaMap.putAll(combalarmQuotaMap);
        allQuotaMap.putAll(huohuaQuotaMap);

        tuanruiWaterAddressMap.put(device_water_code_arr[0],"泉水溪");
        tuanruiWaterAddressMap.put(device_water_code_arr[1],"乌龙沟");
        tuanruiWaterAddressMap.put(device_water_code_arr[2],"潘家垄水库");
        tuanruiWaterAddressMap.put(device_water_code_arr[3],"诸家大塘");
        tuanruiWaterAddressMap.put(device_water_code_arr[4],"霞飞南路");
        deviceCodeMap.put(tuanrui_water_address,tuanruiWaterAddressMap);

        devictTypeMap.put(tsp_type,"大气粉尘在线监测（TSP）");
        devictTypeMap.put(smoke_type,"烟气在线");
        devictTypeMap.put(vocs_type,"VOCs（挥发性有机物检测）");
        devictTypeMap.put(pm25_type,"PM2.5检测");
        devictTypeMap.put(water_type,"雨水、污水排口检测");
        devictTypeMap.put(sweage_type,"污水流量检测");
        devictTypeMap.put(vedio_type,"视频");
        devictTypeMap.put(combustibl_type,"可燃气体检测");
        devictTypeMap.put(huohua_type,"火花报警");
        deviceCodeMap.put(device_type,devictTypeMap);


        Integer count = 0;
        List<String> device_all_code_list = new ArrayList<>();
        for (String code: device_gas_code_arr){
            logger.info("device's code:"+code+",count:"+count);
            device_all_code_map.put(code,count);
            device_all_code_list.add(code);
            allDayAvgQuotaMap.put(code,GAS_Quota_a05002_Rtd);//需要天统计的设备指标关系
            count++;
        }
        for (String code: device_water_code_arr){
            logger.info("device's code:"+code+",count:"+count);
            device_all_code_map.put(code,count);
            device_all_code_list.add(code);
            count++;
        }
        for (String code: device_doppler_code_arr){
            logger.info("device's code:"+code+",count:"+count);
            device_all_code_map.put(code,count);
            device_all_code_list.add(code);
            count++;
        }
        for (String code: device_pm25_code_arr){
            logger.info("device's code:"+code+",count:"+count);
            device_all_code_map.put(code,count);
            device_all_code_list.add(code);
            allDayAvgQuotaMap.put(code,PM_25_Quota_a34004_Avg);//需要天统计的设备指标关系
            allYearAvgQuotaMap.put(code,PM_25_Quota_a34004_Avg);//需要按年统计的设备指标关系
            count++;
        }
        for (String code: device_smokeonline_code_arr){
            logger.info("device's code:"+code+",count:"+count);
            device_all_code_map.put(code,count);
            device_all_code_list.add(code);
            count++;
        }
        for (String code: device_tsp_code_arr){
            logger.info("device's code:"+code+",count:"+count);
            device_all_code_map.put(code,count);
            device_all_code_list.add(code);
            allDayAvgQuotaMap.put(code,TSP_Quota_a34001_Rtd);//需要天统计的设备指标关系
            allDayAvgQuotaMap.put(code,TSP_Quota_a34004_Rtd);//需要天统计的设备指标关系
            count++;
        }
        for (String code: device_combalarm_code_arr){
            logger.info("device's code:"+code+",count:"+count);
            device_all_code_map.put(code,count);
            device_all_code_list.add(code);
            count++;
        }
        for (String code: device_huohuam_code_arr){
            logger.info("device's code:"+code+",count:"+count);
            device_all_code_map.put(code,count);
            device_all_code_list.add(code);
            count++;
        }
        logger.info("device's count:"+count);
        device_all_code_arr = device_all_code_list.toArray(new String[device_all_code_list.size()]);
    }


    public static void main(String[] args) {
        DeviceFinal deviceFinal = new DeviceFinal();
    }

}
